package Work2;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.UnsupportedEncodingException;

public class Readfile1 {

	public static void main(String[] args) {
		//201521123063
		FileReader fr = null;
		try {
			fr = new FileReader("d:/EncodeTest.txt");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		BufferedReader br= new BufferedReader(fr);
		String line;
		try {
			while((line=br.readLine())!=null)
				System.out.println(line);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void convertGBK2UTF8(String src, String dst) throws UnsupportedEncodingException, FileNotFoundException {
		//201521123063
		FileReader fr = new FileReader(src);
		BufferedReader br= new BufferedReader(fr);
		FileOutputStream fileOutputStream=new FileOutputStream(dst);
		OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
		String line = null;
		try {
			while((line=br.readLine())!=null){
				outputStreamWriter.write(line);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			br.close();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		try {
			outputStreamWriter.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
//	public static void main(String[] args) throws Exception{
//		//201521123063
//		BufferedReader br = null;
//		BufferedReader bufferedReader = new BufferedReader(new FileReader("1.txt"));
//		try {
//			FileInputStream fis = new FileInputStream("d:/EncodeTest.txt");
//			InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
//			br = new BufferedReader(isr);
//			String line = null;
//			while((line=br.readLine())!=null)
//				System.out.println(line);
//		} finally{
//			if (br!=null){
//				br.close();
//			}
//		}
//	}
	

}
